#include<bits/stdc++.h>
using namespace std;
int a[100010],out[100010],n;

int fdend(int bg)
{
    for (; bg < n; bg++)
    {
        if (a[bg]<a[bg+1])
            return bg+1;
    }
    return n;
}

int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int end,lend=0,nend,ans;
    cin>>n;
    memset(out,0,sizeof(out));
    for (int i = 0; i < n; i++)
    {   
        cin>>a[i];
    }
    sort(a,a+n);
    end=fdend(0);
    do
    {
        nend=fdend(end);
        if ((end-lend)<=(nend-end))
        {
            for (int q = lend; q < end; q++)
                out[q]=1;
        }
        if ((end-lend)>(nend-end))
        {
            for (int ne=nend-end,m=lend; ne!=0 ; ne--)
                out[m++]=1;                                
        }
        if (nend==n)
            break;
        lend=end;
        end=nend;
    }
    while (1);

    for (int on = 0; on < n; on++)
    {
        if(out[on]!=1)
            ans++;
    }
    
    cout<<ans<<endl;
    fclose(stdin);
    fclose(stdout);
    return 0;
}
